<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/12/28
 * Time: 20:46
 */

namespace app\modules\nullObject;


class Service
{
    /**
     * @var LoggerInterface
     */
    private $_logger;

    /**
     * Service constructor.
     * @param LoggerInterface $logger
     */
    public function __construct(LoggerInterface $logger)
    {
        $this->_logger = $logger;
    }

    public function doSomething()
    {
        // 这里你只是使用它，而不需要通过如：is_null() 检查 $logger 是否已经设置
        $this->_logger->log(__METHOD__);
    }
}